import $getScript from './getScript'

let pm = null
function getCosSdk () {
	if (!pm) {
		pm = new Promise(resolve => {
			if (window.COS) {
				resolve(window.COS)
			} else {
				$getScript({
					src: '//img.yangshipin.cn/assets/cosjssdkv5.min-k6imt5my9wiu.js',
					onLoad () {
						resolve(window.COS)
					}
				})
			}
		})
	}
	return pm
}

export default getCosSdk
